package com.woniuxy.lab.woniu_lab_boss.docker;

import com.woniuxy.lab.woniu_lab_boss.common.Shell;
import lombok.Data;

@Data
public class DockerUtil {

    private Shell shell;

    private final static String DOCKER = "docker ";

    public DockerUtil() {
    }

    public DockerUtil(String host, String username, String password) {
        this.shell = new Shell(host, username, password);
    }

    public static DockerUtil getDocker(String host, String username, String password){
        return new DockerUtil(host, username, password);
    }

    public Image getImage(){
        return new Image(shell);
    }

    public Container getContainer(){
        return new Container(shell);
    }

    public Network getNetwork(){
        return new Network(shell);
    }

    public Run getRun(){
        return new Run(shell);
    }

    // 启动docker
    public String startDocker(){
        return shell.execCommand("systemctl start docker");
    }

    // build指令
    public String build(String nameOrId){
        return shell.execCommand(DOCKER+"build -t "+nameOrId);
    }

}
